<template>
  <div class="medicine_price">
    <div class="medicine_head">
      <div class="medicine_font">Medicine Price</div>
    </div>
    <nuxt-link target="_blank" :to="'/drugDetail/' + item.id + '.html'" class="medicine_card" v-for="(item,index) in newsList" :key="index">
      <div class="medicine_title">{{ item.name }}</div>
      <div class="medicine_font">{{ subfont(item) }}</div>
      <div class="medicine_info">
        <div class="additional">Article Source: {{ item.authorSource }} &emsp; Page views: {{ item.hits }}</div>
        <div class="additional">{{ item.updateTime }}</div>
      </div>
    </nuxt-link>
  </div>
</template>

<script>
export default {
  props:['newsList'],
  methods: {
    subfont (item) {
      if (null != item.content) {
        if (item.content.length > 200) {
          return item.content.replace(/<[^>]+>/g, '').replace(/\s+/g, ' ').trim().slice(0, 200) + '...'
        } else {
          return item.content.replace(/<[^>]+>/g, '').replace(/\s+/g, ' ').trim()
        }
      } else {
        return ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.medicine_price{
  margin-top: 24px;
  .medicine_head{
    border-bottom: 1px solid #CBD1D7;
    .medicine_font{
      width: 130px;
      font-weight: bold;
      font-size: 18px;
      color: #0041A3;
      line-height: 62px;
      border-bottom: 4px solid #0041A3;
    }
  }
  .medicine_card{
    display: block;
    margin-top: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(203,209,215,0.4);
    cursor: pointer;
    .medicine_title{
      font-weight: bold;
      font-size: 18px;
      color: #2E343E;
      line-height: 28px;

      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 1;
    }
    .medicine_font{
      font-weight: 400;
      font-size: 16px;
      color: #616469;
      line-height: 28px;
      margin-top: 8px;

      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }
    .medicine_info{
      display: flex;
      justify-content: space-between;
      margin-top: 8px;
      .additional{
        font-weight: 400;
        font-size: 12px;
        color: #8A95A2;
        line-height: 24px;
      }
    }
  }
}
</style>